package com.yowasa.xiuxian.engine.travel.adventure;

import com.yowasa.xiuxian.engine.travel.AdventureInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.MapEnum;
import com.yowasa.xiuxian.service.helper.UserHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 敲诈勒索 损失10摩拉
 */
@Component
public class QiaoZhaLeSuo implements AdventureInterface {
    @Autowired
    private UserHelper userHelper;

    @Override
    public Set<MapEnum> limitMaps() {
        //村庄only
        return Arrays.stream(MapEnum.values()).filter(e -> e.getType() == 1).collect(Collectors.toSet());
    }

    @Override
    public String exec(UserBO user) {
        String msg = "你看到路边有个菜篮子，你好奇靠近，突然背后出现一个老太太说你偷了他的东西，强迫你赔偿了10摩拉";
        if (user.getUserConfig().getGold() >= 10) {
            user.getUserConfig().setGold(user.getUserConfig().getGold() - 10);
            userHelper.lockUser(user, 10, user.getName() + "游历中");
        } else {
            msg += "你没有足够的摩拉赔付，对方追着你告了一个月";
            userHelper.lockUser(user, 30, user.getName() + "打官司中");
        }
        return msg;
    }

    @Override
    public boolean isConflict() {
        return true;
    }
}
